#include "student.h"  
#include <stdio.h> 
//main分支添加的注释
void addStudent(Student *stus, int *count) {
    if (*count >=3) {
        printf("学生数量已达上限！\n");
        return;
    }
    printf("请输入姓名：");
    scanf("%s", stus[*count].name);
    printf("请输入学号：");
    scanf("%d", &stus[*count].id);
    printf("请输入成绩：");
    scanf("%f", &stus[*count].score);
    (*count)++;
    printf("添加成功！当前共%d名学生\n", *count);
}

void queryStudent(Student *stus, int count) {
    if (count == 0) {
        printf("暂无学生信息！\n");
        return;
    }
    printf("===== 学生列表 =====\n");
    for (int i = 0; i < count; i++) {
        printf("序号：%d\n", i + 1);
        printf("姓名：%s\n", stus[i].name);
        printf("学号：%d\n", stus[i].id);
        printf("成绩：%.1f\n", stus[i].score);
        printf("-------------------\n");
    }
}

// 3. 主函数（程序入口）
int main() {
    int count = 0;
    int choice;
    Student students[3];  

    while (1) {
        printf("\n1. 添加学生\n2. 查询学生\n3. 退出\n请选择：");
        scanf("%d", &choice);
        if (choice == 3) break;
        switch (choice) {
            case 1:
                addStudent(students, &count);
                break;
            case 2:
                queryStudent(students, count);
                break;
            default:
                printf("输入错误，请重新选择！\n");
        }
    }
    printf("程序退出！\n");
    return 0;
}
